package com.street.mapper;

import com.street.entity.Dish;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {

    @Select("select id, name, shop_id, price, image, description, status, category_id from dish where shop_id=#{shopId}")
    List<Dish> selectByShopId(Integer shopId);
    @Select("select id, name, category_id, price,shop_id, image, description, status" +
            " from dish where id=#{id}")
    Dish selectById(Long dishId);



    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into dish(name,price,shop_id, image, description, status)" +
            "values (#{name},#{price},#{shopId},#{image},#{description},#{status})"
    )
    void insert(Dish dish);

    @Update("update dish set name=#{name},price=#{price},image=#{image}," +
            "description=#{description} where id=#{id}" )
    void update(Dish dish);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Integer id);

    @Update("update dish set status=#{status} where id =#{dishId}")
    void updateStatus(Integer status, Integer dishId);
}
